<?php
class Soooner_View_Helper_Form
{
	/*
	 * 创建表单元素
	 */
    public static function form($attr)
    {
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $attr['action']  = empty($attr['action']) ? '' : ' action="'.$attr['action'].'"';
        $attr['method']  = empty($attr['method']) ? ' method="post"' : ' method="'.$attr['method'].'"';
        $attr['name']    = empty($attr['name']) ? '' : ' name="'.$attr['name'].'"';
        $attr['id']      = empty($attr['id']) ? '' : ' id="'.$attr['id'].'"';
        $attr['addon']   = empty($attr['addon']) ? '' : ' '.$attr['addon'];
        return '<form' . $attr['action'] . $attr['method'] . $attr['name'] . $attr['id'] . $attr['addon'] .'>';
    }
	public static function editor($attr)
	{
		$args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $rows  = empty($attr['rows']) ? 10 : $attr['rows'];
        $cols  = empty($attr['cols']) ? 50 : $attr['cols'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
//        $character  = empty($attr['character']) ? 0 : $attr['character'];
//        $maxlength  = empty($attr['maxlength']) ? 0 : $attr['maxlength'];
		if(!$id) $id = $name;
//		if($character && $maxlength)
//		{
//			$data = ' <img src="images/icon.gif" width="12"> 还可以输入 <font id="ls_'.$id.'" color="#ff0000;">'.$maxlength.'</font> 个字符！<br />';
//		}
		//$data .= "<textarea name=\"$name\" id=\"$id\" rows=\"$rows\" cols=\"$cols\" class=\"$class\" width=1 height=1 $ext>$value</textarea>";
		//简单封装
		$data .= "<textarea id='$id' name='$name' class='$class' $ext>$value</textarea>";
		$data .= "<script type=\"text/javascript\" src=\"/scripts/fckeditor/fckeditor.js\"></script>\n";
		$data .= "<script language=\"JavaScript\" type=\"text/JavaScript\">\n";
		$data .= "function FCKeditor_OnComplete( editorInstance ){editorInstance.SwitchEditMode();}\n";
		$data .= "var sBasePath = \"/scripts/fckeditor/\";\n";
		$data .= "var oFCKeditor = new FCKeditor( '".$id."' ) ;\n";
		$data .= "oFCKeditor.BasePath = sBasePath ; \n";
		$data .= "oFCKeditor.Height = '300'; \n";
		$data .= "oFCKeditor.Width	= '90%' ;\n";
		$data .= "oFCKeditor.ToolbarSet	= 'basic' ;\n";
		$data .= "oFCKeditor.ReplaceTextarea();</script>\n";
		return $data;
	}
	public static function sinaeditor($attr){
		$args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $id  = empty($attr['id']) ? '' : $attr['id'];
        $name  = empty($attr['name']) ? '' : $attr['name'];        
        $value  = empty($attr['value']) ? '' : $attr['value'];     
        $class  = empty($attr['class']) ? '' : $attr['class'];   
        $cols  = empty($attr['cols']) ? 50 : $attr['cols'];        
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $width = 650;
        $height = 460;
        
        //$ReadCookie=$this->AutoSave?1:0;
        $ReadCookie = 0;        
        $str = "<textarea name=\"$name\" id=\"$id\" style=\"display:none;\" >$value</textarea>\n";
		$str .= "<iframe src=\"/scripts/edit/editor.htm?id=$id&ReadCookie=$ReadCookie\" frameBorder=\"0\" marginHeight=\"0\" marginWidth=\"0\" scrolling=\"No\" width=\"$width\" height=\"$height\"></iframe>";
		return $str;
	}
    /*
	public static function editor($textareaid = 'content', $toolbar = 'standard', $width = '100%', $height = 400, $isshowext = 1)
	{
		global $PHPCMS, $mod, $file, $catid, $_userid;
		$str = "<script type=\"text/javascript\" src=\"fckeditor/fckeditor.js\"></script>\n<script language=\"JavaScript\" type=\"text/JavaScript\">var SiteUrl = \"".SITE_URL."\"; var Module = \"".$mod."\"; var sBasePath = \"".SITE_URL."\" + 'fckeditor/'; var oFCKeditor = new FCKeditor( '".$textareaid."' ) ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.Height = '".$height."'; oFCKeditor.Width	= '".$width."' ; oFCKeditor.ToolbarSet	= '".$toolbar."' ;oFCKeditor.ReplaceTextarea();";
		if($_userid && $isshowext)
		{
			$str .= "editor_data_id += '".$textareaid."|';if(typeof(MM_time)=='undefined'){MM_time = setInterval(update_editor_data,".($PHPCMS['editor_interval_data']*1000).");}";
		}
		$str .= "</script>";
		if($isshowext)
		{
			$str .= "<div style='width:$width;text-align:left'>";
			if($_userid)
			{
				$str .= "<span style='float:right;height:22px'>";
				if(defined('IN_ADMIN') && $mod == 'phpcms' && $file == 'content')
				{
					$str .= "<span style='padding:1px;margin-right:10px;background-color: #fefe;border:#006699 solid 1px;'><a href='javascript:insert_page(\"$textareaid\")' title='在光标处插入分页标记'>分页</a></span>";
					$str .= "<span style='padding:1px;margin-right:10px;background-color: #fefe;border:#006699 solid 1px;'><a href='javascript:insert_page_title(\"$textareaid\")' title='在光标处插入带子标题的分页标记'>子标题</a></span>";
				}
				$str .= "<span style='padding:1px;margin-right:10px;background-color: #fefe;border:#006699 solid 1px;'><div id='page_title_div' style='background-color: #fff;border:#006699 solid 1px;position:absolute;z-index:10;padding:1px;display:none;right:80px;'>
				<table cellpadding='0' cellspacing='1' border='0'><tr><td >请输入子标题名称：<span id='msg_page_title_value'></span></td><td><span style='cursor:pointer;float:right;' onclick='javascript:$(\"#page_title_div\").hide()'>×</span></td>
				<tr><td colspan='2'><input name='page_title_value' id='page_title_value' value='' size='40'>&nbsp;<input type='button' value=' 确定 ' onclick=insert_page_title(\"$textareaid\",1)></td></tr>
				</table></span></div>";

				$str .= "<span style='padding:1px;margin-right:10px;background-color: #fefe;border:#006699 solid 1px;'><div id='".$textareaid."_div' style='background-color: #fff;border:#006699 solid 1px;position:absolute;z-index:10;padding:5px;display:none;right:60px;'>
						<table cellpadding='0' cellspacing='1' border='0'><tr><td>
						<div>";
				for($i=1; $i<=$PHPCMS['editor_max_data_hour']; $i++)
				{
					$bold = $i==1 ? "font-weight: bold;" : '';
					$str .= "<a href='javascript:get_editor_data_list(\"".$textareaid."\",$i)' class='hour' style='border:#cccccc solid 1px;margin:2px;padding-left:4px;padding-right:4px;$bold' title='$i 小时'>$i</a>";
				}
				$str .= "</div></td><td><span style='cursor:pointer;' onclick='javascript:$(\"#".$textareaid."_div\").hide()'>×</span></td></tr></table><ul id='".$textareaid."_lists' style='height:200px;width:140px;overflow:auto;'></ul></div><a href='javascript:get_editor_data_list(\"".$textareaid."\",1)' title='点击恢复数据'>恢复数据</a></span></span>";
			}
			$str .= "<img src=\"".SITE_URL."images/editor_add.jpg\" title='增加编辑器高度' tag='1' fck=\"".$textareaid."\"/>&nbsp;  <img src=\"".SITE_URL."images/editor_diff.jpg\" title='减少编辑器高度' tag='0' fck=\"".$textareaid."\"/></div>";
		}
		$str .= "<div id=\"MM_file_list_".$textareaid."\" style=\"text-align:left\"></div><div id='FilePreview' style='Z-INDEX: 1000; LEFT: 0px; WIDTH: 10px; POSITION: absolute; TOP: 0px; HEIGHT: 10px; display: none;'></div><div id='".$textareaid."_save'></div>";
		return $str;
	}
	*/

    /*
     * 创建日期选择窗口 
     * 第五个参数代表是否显示时间
     */
	public static function datetime($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $isdatetime = empty($attr['cols']) ? 0 : $attr['cols'];
		if($value == '0000-00-00 00:00:00') $value = '';
		$id = preg_match("/\[(.*)\]/", $name, $m) ? $m[1] : $name;
		if($isdatetime)
		{
			$size = 21;
			$format = '%Y-%m-%d %H:%M';
			$showsTime = 'true';
		}
		else
		{
			$size = 10;
			$format = '%Y-%m-%d';
			$showsTime = 'false';
		}
		$str = '';
		if(!defined('CALENDAR_INIT'))
		{
			define('CALENDAR_INIT', 1);
			$str .= '<link rel="stylesheet" type="text/css" href="/styles/calendar-blue.css"/>
			        <script type="text/javascript" src="/js/calendar.js"></script>';
		}
		$str .= '<input type="text" name="'.$name.'" id="'.$id.'" value="'.$value.'" size="'.$size.'" readonly>&nbsp;';
		$str .= '<script language="javascript" type="text/javascript">
					date = new Date();document.getElementById ("'.$id.'").value="'.$value.'";
					Calendar.setup({
						inputField     :    "'.$id.'",
						ifFormat       :    "'.$format.'",
						showsTime      :    '.$showsTime.',
						timeFormat     :    "24"
					});
				 </script>';
		return $str;
	}

	/*
	 * 创建验证码
	 */
	public static function checkcode($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? 'checkcode' : $attr['name'];
        $size  = empty($attr['size']) ? 4 : $attr['size'];
        $extra  = empty($attr['extra']) ? '' : $attr['extra'];
		return '<input name="'.$name.'" id="'.$name.'" type="text" size="'.$size.'" '.$extra.' style="ime-mode:disabled;"> <img src="'.SITE_URL.'checkcode.php" id="checkcode" onclick="this.src=\''.SITE_URL.'checkcode.php?id=\'+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/>';
	}

	/*
	function style($name = 'style', $style = '')
	{
		global $styleid, $LANG;
		if(!$styleid) $styleid = 1; else $styleid++;
		$color = $strong = '';
		if($style)
		{
			list($color, $b) = explode(' ', $style);
		}
		$styleform = "<option value=\"\">".$LANG['color']."</option>\n";
		for($i=1; $i<=15; $i++)
		{
			$styleform .= "<option value=\"c".$i."\" ".($color == 'c'.$i ? "selected=\"selected\"" : "")." class=\"bg".$i."\"></option>\n";
		}
		$styleform = "<select name=\"style_color$styleid\" id=\"style_color$styleid\" onchange=\"document.all.style_id$styleid.value=document.all.style_color$styleid.value;if(document.all.style_strong$styleid.checked)document.all.style_id$styleid.value += ' '+document.all.style_strong$styleid.value;\">\n".$styleform."</select>\n";
		$styleform .= " <label><input type=\"checkbox\" name=\"style_strong$styleid\" id=\"style_strong$styleid\" value=\"b\" ".($b == 'b' ? "checked=\"checked\"" : "")." onclick=\"document.all.style_id$styleid.value=document.all.style_color$styleid.value;if(document.all.style_strong$styleid.checked)document.all.style_id$styleid.value += ' '+document.all.style_strong$styleid.value;\"> ".$LANG['bold'];
		$styleform .= "</label><input type=\"hidden\" name=\"".$name."\" id=\"style_id$styleid\" value=\"".$style."\">";
		return $styleform;
	}
	*/

	/*
	 * 创建输入框（默认类型：文本框）
	 */
	public static function text($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value'])&&$attr['value']!=0 ? '' : $attr['value'];
        $type  = empty($attr['type']) ? 'text' : $attr['type'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $minlength  = empty($attr['minlength']) ? '' : $attr['minlength'];
        $maxlength  = empty($attr['maxlength']) ? '' : $attr['maxlength'];
//        $errortips  = empty($attr['errortips']) ? '' : $attr['errortips'];
		if(!$id) $id = $name;
		$checkthis = '';
//		$showerrortips = "字符长度必须为".$minlength."到".$maxlength."位";
        if($minlength)
        {
            $checkthis = " minlength=\"$minlength\"";
        }
        if($maxlength)
        {
            $checkthis .= " maxlength=\"$maxlength\"";
        }
		return "<input type=\"$type\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $checkthis $ext/> ";
	}
	
    /*
	 * 创建密码输入框
	 */
	public static function password($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $type  = empty($attr['type']) ? 'password' : $attr['type'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $minlength  = empty($attr['minlength']) ? '' : $attr['minlength'];
        $maxlength  = empty($attr['maxlength']) ? '' : $attr['maxlength'];
//        $errortips  = empty($attr['errortips']) ? '' : $attr['errortips'];
		if(!$id) $id = $name;
		$checkthis = '';
//		$showerrortips = "字符长度必须为".$minlength."到".$maxlength."位";
        if($minlength)
        {
            $checkthis = " minlength=\"$minlength\"";
        }
        if($maxlength)
        {
            $checkthis .= " maxlength=\"$maxlength\"";
        }
		return "<input type=\"$type\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $checkthis $ext/> ";
	}
	
 	/*
	 * 创建隐藏表单
	 */
	public static function hidden($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $type  = empty($attr['type']) ? 'hidden' : $attr['type'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $minlength  = empty($attr['minlength']) ? '' : $attr['minlength'];
        $maxlength  = empty($attr['maxlength']) ? '' : $attr['maxlength'];
//        $errortips  = empty($attr['errortips']) ? '' : $attr['errortips'];
		if(!$id) $id = $name;
		$checkthis = '';
//		$showerrortips = "字符长度必须为".$minlength."到".$maxlength."位";
        if($minlength)
        {
            $checkthis = " minlength=\"$minlength\"";
        }
        if($maxlength)
        {
            $checkthis .= " maxlength=\"$maxlength\"";
        }
		return "<input type=\"$type\" name=\"$name\" id=\"$id\" value=\"$value\" /> ";
	}

	/*
	 * 创建文本区域
	 */
	public static function textarea($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $rows  = empty($attr['rows']) ? 4 : $attr['rows'];
        $cols  = empty($attr['cols']) ? 30 : $attr['cols'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
//        $character  = empty($attr['character']) ? 0 : $attr['character'];
//        $maxlength  = empty($attr['maxlength']) ? 0 : $attr['maxlength'];
		if(!$id) $id = $name;
//		if($character && $maxlength)
//		{
//			$data = ' <img src="images/icon.gif" width="12"> 还可以输入 <font id="ls_'.$id.'" color="#ff0000;">'.$maxlength.'</font> 个字符！<br />';
//		}
		$data .= "<textarea name=\"$name\" id=\"$id\" rows=\"$rows\" cols=\"$cols\" class=\"$class\" $ext>$value</textarea>";
		return $data;
	}

	/*
	 * 创建下拉菜单（单选）
	 */
	public static function select($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }
        $defaultOptions=array(0=>"否",1=>"是");
        $options  = empty($attr['options']) ? $defaultOptions : $attr['options'];
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 1 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
		if(!$id) $id = $name;
		if(!is_array($options)) $options = Soooner_View_Helper_Form::_option($options);
		if($size >= 1) $size = " size=\"$size\"";
		if($class) $class = " class=\"$class\"";
		$data .= "<select name=\"$name\" id=\"$id\" $size $class $ext>";
		foreach($options as $k=>$v)
		{
			$selected = $k == $value ? 'selected' : '';
			$data .= "<option value=\"$k\" $selected>$v</option>\n";
		}
		$data .= '</select>';
		return $data;
	}

	/*
	 * 创建下拉菜单（多选）
	 */
	public static function multiple($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $options  = empty($attr['options']) ? '' : $attr['options'];
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 3 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
		if(!$id) $id = $name;
		if(!is_array($options)) $options = Soooner_View_Helper_Form::_option($options);
		$size = max(intval($size), 3);
		if($class) $class = " class=\"$class\"";
		$value = strpos($value, ',') ? explode(',', $value) : array($value);
		$data .= "<select name=\"$name\" id=\"$id\" multiple=\"multiple\" size=\"$size\" $class $ext>";
		foreach($options as $k=>$v)
		{
			$selected = in_array($k, $value) ? 'selected' : '';
			$data .= "<option value=\"$k\" $selected>$v</option>\n";
		}
		$data .= '</select>';
		return $data;
	}

	/*
	 * 创建复选框
	 */
    public static function checkbox($attr)
    {
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $options  = empty($attr['options']) ? '' : $attr['options'];
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $cols  = empty($attr['cols']) ? 5 : $attr['cols'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $width  = empty($attr['width']) ? 100 : $attr['width'];
        if(!$options) return '';
        if(!$id) $id = $name;
        if(!is_array($options)) $options = Soooner_View_Helper_Form::_option($options);
        $i = 1;
//        $data = '<input type="hidden"'.$name . $id.' value="-99">';
        $data = '';
        if($class) $class = " class=\"$class\"";
        if($value != '') $value = strpos($value, ',') ? explode(',', $value) : array($value);
        foreach($options as $k=>$v)
        {
            $checked = ($value && in_array($k, $value)) ? 'checked' : '';
            $data .= "<span style=\"width:{$width}px\"><label><input type=\"checkbox\" boxid=\"{$id}\" name=\"{$name}[]\" id=\"{$id}\" value=\"{$k}\" style=\"border:0px\" $class {$ext} {$checked}/> {$v}</label></span>\n ";
            if($i%$cols == 0) $data .= "<br />\n";
            $i++;
        }
        return $data;
    }

    /*
     * 创建单选框
     */
	public static function radio($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }
        $defaultOptions=array(1=>"是",0=>"否");
        $options  = empty($attr['options']) ? $defaultOptions : $attr['options'];
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $cols  = empty($attr['cols']) ? 5 : $attr['cols'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $width  = empty($attr['width']) ? 100 : $attr['width'];
        if(!$id) $id = $name;
		if(!is_array($options)) $options = Soooner_View_Helper_Form::_option($options);
		$i = 1;
        if($name) $name = " name=\"$name\"";
        if($id) $id = " id=\"$id\"";
		$data = '';
		if($class) $class = " class=\"$class\"";
		foreach($options as $k=>$v)
		{
			$checked = $k == $value ? 'checked' : '';
			$data .= "<span style=\"width:{$width}px\"><label><input type=\"radio\"" . $name . $id." value=\"{$k}\" style=\"border:0px\" $class {$ext} {$checked}/> {$v}</label></span> ";
			if($i%$cols == 0) $data .= "<br />\n";
			$i++;
		}
		return $data;
	}

	/*
	 * 变换选项数据形式
	 */
	public static function _option($options, $s1 = "\n", $s2 = '|')
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

		$options = explode($s1, $options);
		foreach($options as $option)
		{
			if(strpos($option, $s2))
			{
				list($name, $value) = explode($s2, trim($option));
			}
			else
			{
				$name = $value = trim($option);
			}
			$os[$value] = $name;
		}
		return $os;
	}

	/*
	 * 创建图像域
	 */
	public static function image($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }
	 	if(isset($args[7])&&''!=$args[7]) {
            $attr['webheader'] = $args[7];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $modelid  = empty($attr['modelid']) ? 0 : $attr['modelid'];
        $fieldid  = empty($attr['fieldid']) ? 0 : $attr['fieldid'];
        $webheader  = empty($attr['webheader']) ? '' : $attr['webheader'];
		if(!$id) $id = $name;
		$result = "";
		if(!defined('IMAGE_INIT'))
		{	
			define('IMAGE_INIT', 1);
			$result .= "<script type=\"text/javascript\" src=\"/js/common.js\"></script>";
		}
		$result .= "<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/>
		<input type=\"button\" name=\"{$name}_upimage\" id=\"{$id}_upimage\" value=\"选择图片\" style=\"width:80px\" onclick=\"javascript:openwinx('/scripts/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=/Connectors/connector&field={$id}','upload','650','350')\"/>
		<img name=\"view$name\" id=\"view$id\" src=\"$value\">
		<hidden name=\"webheader$name\" id=\"webheader$id\" value=\"$webheader\">";		
		return $result;
	}

/*
	 * 创建chem域
	 */
	public static function chem($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }
	 	
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $modelid  = empty($attr['modelid']) ? 0 : $attr['modelid'];
        $fieldid  = empty($attr['fieldid']) ? 0 : $attr['fieldid'];
		if(!$id) $id = $name;
		$result = "";
		if(!defined('CHEM_INIT'))
		{	
			define('CHEM_INIT', 1);
			$result .= "<script type=\"text/javascript\" src=\"/scripts/chem/chemdraw.js\"></script>\n";
			$result .= "<script type=\"text/javascript\"> cd_includeWrapperFile(\"\"); </script>\n";
		}
		$result .= "<input type=\"hidden\" name=\"$name\" id=\"$id\" value=\"$value\"><br>\n";	
		$result .= "<div onmouseout=\"getv('$name')\" style=\"border:1px solid black;width:300px;height:250px\"><script language=\"JavaScript\"> cd_insertObjectStr(\"<embed  align='baseline' border='0' width='300' height='250' type='chemical/x-cdx' name='v_$name' id='v_$id'>\"); </script></div>\n";
		$result .= "<script language=\"JavaScript\">setv('$name','$value');</script>\n";
		$result .= "<noembed>Sorry, your browser does not support plugins.</noembed>\n";
		return $result;
	}
	
	public static function chemview($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }
	 	
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $width = empty($attr['class']) ? '250' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $modelid  = empty($attr['modelid']) ? 0 : $attr['modelid'];
        $fieldid  = empty($attr['fieldid']) ? 0 : $attr['fieldid'];
		if(!$id) $id = $name;
		$result = "";
		if(!defined('CHEM_INIT'))
		{	
			define('CHEM_INIT', 1);
			$result .= "<script type=\"text/javascript\" src=\"/scripts/chem/chemdraw.js\"></script>\n";
			$result .= "<script type=\"text/javascript\"> cd_includeWrapperFile(\"\"); </script>\n";
		}
		$result .= "<input type=\"hidden\" name=\"$name\" id=\"$id\" value=\"$value\"><br>\n";	
		$result .= "<div onmouseout=\"getv('$name')\" style=\"border:1px solid black;width:".$width."px;height:200px\"><script language=\"JavaScript\"> cd_insertObjectStr(\"<embed  align='baseline' border='0' viewOnly='1' shrinkToFit='1' width='$width' height='200' type='chemical/x-cdx' name='v_$name' id='v_$id'>\"); </script></div>\n";
		$result .= "<script language=\"JavaScript\">setv('$name','$value');</script>\n";
		$result .= "<noembed>Sorry, your browser does not support plugins.</noembed>\n";
		return $result;
	}
	
	public static function chempop($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $modelid  = empty($attr['modelid']) ? 0 : $attr['modelid'];
        $fieldid  = empty($attr['fieldid']) ? 0 : $attr['fieldid'];
		if(!$id) $id = $name;
		$result = "";
		if(!defined('CHEMPOP_INIT'))
		{	
			define('CHEMPOP_INIT', 1);
			$result .= "<script type=\"text/javascript\" src=\"/js/common.js\"></script>";
		}
		$result .= "<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/>
		<input type=\"button\" name=\"{$name}_chempop\" id=\"{$id}_chempop\" value=\"SMILE\" style=\"width:80px\" onclick=\"javascript:openwinxx('/scripts/chem/cheminput.htm?s={$value}&c={$id}','sss','310','280')\"/>
		";
		return $result;
	}

	/*
	 * 创建文件域
	 */
	public static function file($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $modelid  = empty($attr['modelid']) ? 0 : $attr['modelid'];
        $fieldid  = empty($attr['fieldid']) ? 0 : $attr['fieldid'];
		if(!$id) $id = $name;
		$result = "";
		if(!defined('IMAGE_INIT'))
		{	
			define('IMAGE_INIT', 1);
			$result .= "<script type=\"text/javascript\" src=\"/js/common.js\"></script>";
		}
		$result .= "<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/>
		<input type=\"button\" name=\"{$name}_upimage\" id=\"{$id}_upimage\" value=\"选择文件\" style=\"width:80px\" onclick=\"javascript:openwinx('/scripts/fckeditor/editor/filemanager/browser/default/browser.html?Type=File&Connector=/Connectors/connector&field={$id}','upload','650','350')\"/>
		";
		return $result;
	}
	
/*
	 * 创建文件域
	 */
	public static function sinafile($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 23 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
        $modelid  = empty($attr['modelid']) ? 0 : $attr['modelid'];
        $fieldid  = empty($attr['fieldid']) ? 0 : $attr['fieldid'];
		if(!$id) $id = $name;
		$result = "";
		if(!defined('sinafile_INIT'))
		{	
			define('sinafile_INIT', 1);
			$result .= "<script type=\"text/javascript\" src=\"/js/common.js\"></script>";
		}
		$result .= "<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/>
		<input type=\"button\" name=\"{$name}_upimage\" id=\"{$id}_upimage\" value=\"...\" style=\"width:40px\" onclick=\"javascript:openwinx('/scripts/edit/editor/attach1.htm?field=$id','upload','350','150')\"/>
		";
		return $result;
	}

	/*
	 * 创建文件上传域
	 */
	public static function downfile($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 50 : $attr['size'];
        $mode  = empty($attr['mode']) ? '' : $attr['mode'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $ext  = empty($attr['ext']) ? '' : $attr['ext'];
		if(!$id) $id = $name;
		$mode = "&mode=".$mode;
		return "<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $ext/> <input type=\"hidden\" name=\"{$id}_aid\" value=\"0\"> <input type=\"button\" name=\"{$name}_upfile\" id=\"{$id}_upfile\" value=\"上传文件\" style=\"width:60px\" onclick=\"javascript:openwinx('?mod=phpcms&file=upload&uploadtext={$id}{$mode}','upload','390','180')\"/>";
	}

	/*
	 * 创建图片上传域
	 */
	public static function upload_image($attr)
	{
        $args = func_get_args();
        if(isset($args[1])&&''!=$args[1]) {
            $attr['id'] = $args[1];
        }
        if(isset($args[2])&&''!=$args[2]) {
            $attr['name'] = $args[2];
        }
        if(isset($args[3])&&''!=$args[3]) {
            $attr['value'] = $args[3];
        }
        if(isset($args[4])&&''!=$args[4]) {
            $attr['class'] = $args[4];
        }
        if(isset($args[5])&&''!=$args[5]) {
            $attr['cols'] = $args[5];
        }
        if(isset($args[6])&&''!=$args[6]) {
            $attr['options'] = $args[6];
        }

        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 50 : $attr['size'];
        $class  = empty($attr['class']) ? '' : $attr['class'];
        $property  = empty($attr['property']) ? '' : $attr['property'];
		if(!$id) $id = $name;
		return "<input type=\"text\" name=\"$name\" id=\"$id\" value=\"$value\" size=\"$size\" class=\"$class\" $property/> <input type=\"button\" name=\"{$name}_upimage\" id=\"{$id}_upimage\" value=\"上传图片\" style=\"width:60px\" onclick=\"javascript:openwinx('?mod=phpcms&file=upload&uploadtext={$id}','upload','380','350')\"/>";
	}

	public static function selecttemplate($attr)
	{
		$args = func_get_args();
		$options = $GLOBALS['application']->getOptions();
    	$templatedir = $options["templatedir"];//前台模板路径
		include $templatedir."name.inc.php";//产生变量 $templatelist
		$files = array_map('basename', glob($templatedir.$args[6].'*.html'));
		$templates = array(''=>'请选择');
		foreach($files as $file)
		{
			$key = substr($file, 0, -5);
			$templates[$key] = isset($templatelist[$file]) ? $templatelist[$file].'('.$file.')' : $file;
		}
		ksort($templates);
		$args[6] = $templates;
		return Soooner_View_Helper_Form::select($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6]);
	}
	

	/*
	function select_file($attr)
	{
        $name  = empty($attr['name']) ? '' : $attr['name'];
        $id  = empty($attr['id']) ? '' : $attr['id'];
        $value  = empty($attr['value']) ? '' : $attr['value'];
        $size  = empty($attr['size']) ? 30 : $attr['size'];
        $catid  = empty($attr['catid']) ? 0 : $attr['catid'];
        $isimage  = empty($attr['isimage']) ? 0 : $attr['isimage'];
		if(!$id) $id = $name;
		return "<input type='text' name='$name' id='$id' value='$value' size='$size' /> <input type='button' value='浏览...' style='cursor:pointer;' onclick=\"file_select('$id', $catid, $isimage)\">";
	}
	*/

	/*
	function select_module($name = 'module', $id ='', $alt = '', $value = '', $property = '')
	{
		global $MODULE;
		if($alt) $arrmodule = array('0'=>$alt);
		foreach($MODULE as $k=>$v)
		{
			$arrmodule[$k] = $v['name'];
		}
		if(!$id) $id = $name;
		return Soooner_View_Helper_Form::select($arrmodule, $name, $id, $value, 1, '', $property);
	}
	*/

	/*
	function select_model($name = 'modelid', $id ='', $alt = '', $modelid = '', $property = '')
	{
		global $MODEL;
		if($alt) $arrmodel = array('0'=>$alt);
		foreach($MODEL as $k=>$v)
		{
			if($v['modeltype'] > 0) continue;
			$arrmodel[$k] = $v['name'];
		}
		if(!$id) $id = $name;
		return Soooner_View_Helper_Form::select($arrmodel, $name, $id, $modelid, 1, '', $property);
	}
	*/

	/*
	function select_member_model($name = 'modelid', $id = '', $alt = '', $modelid = '', $property = '')
	{
		global $MODEL;
		if($alt) $arrmodel = array('0'=>$alt);
		foreach($MODEL as $k=>$v)
		{
			if($v['modeltype'] == '2')
			{
				$arrmodel[$k] = $v['name'];
			}
		}
		if(!$id) $id = $name;
		return Soooner_View_Helper_Form::select($arrmodel, $name, $id, $modelid, 1, '', $property);
	}
	*/

	/*
	function select_category($module = 'phpcms', $parentid = 0, $name = 'catid', $id ='', $alt = '', $catid = 0, $property = '', $type = 0, $optgroup = 0)
	{
		global $tree, $CATEGORY;
		if(!is_object($tree))
		{
			require_once 'tree.class.php';
			$tree = new tree;
		}
		if(!$id) $id = $name;
		if($optgroup) $optgroup_str = "<optgroup label='\$name'></optgroup>";
		$data = "<select name='$name' id='$id' $property>\n<option value='0'>$alt</option>\n";
		if(is_array($CATEGORY))
		{
			$categorys = array();
			foreach($CATEGORY as $id=>$cat)
			{
				if(($type == 2 && $cat['type'] ==2) || ($type == 1 && $cat['type'])) continue;
				if($cat['module'] == $module) $categorys[$id] = array('id'=>$id, 'parentid'=>$cat['parentid'], 'name'=>$cat['catname']);
			}
			$tree->tree($categorys);
			$data .= $tree->get_tree($parentid, "<option value='\$id' \$selected>\$spacer\$name</option>\n", $catid, '' , $optgroup_str);
		}
		$data .= '</select>';
		return $data;
	}
	*/

	/*
	function select_pos($name = 'posid', $id ='', $posids = '', $cols = 1, $width = 100)
	{
		global $db,$priv_role, $POS;
		if(!$id) $id = $name;
		$pos = array();
		foreach($POS as $posid=>$posname)
		{
			if($priv_role->check('posid', $posid)) $pos[$posid] = str_cut($posname, 16, '');
		}
		return Soooner_View_Helper_Form::checkbox($pos, $name, $id, $posids, $cols, '', '', $width);
	}
	*/

	/*
	function select_group($name = 'groupid', $id ='', $groupids = '', $cols = 1, $width = 100)
	{
		global $db, $GROUP;
		if(!$id) $id = $name;
		return Soooner_View_Helper_Form::checkbox($GROUP, $name, $id, $groupids, $cols, '', '', $width);
	}
	*/

	/*
	function select_type($module = 'phpcms', $name = 'typeid', $id ='', $alt = '', $typeid = 0, $property = '', $modelid = 0)
	{
		$types = subtype($module, $modelid);
		if(!$id) $id = $name;
		$data = "<select name='$name' id='$id' $property>\n<option value='0'>$alt</option>\n";
		foreach($types as $id=>$t)
		{
			$selected = $id == $typeid ? 'selected' : '';
			$data .= "<option value='$id' $selected>$t[name]</option>\n";
		}
		$data .= '</select>';
		return $data;
	}
	*/

	/*
	function select_area($name = 'areaid', $id ='', $alt = '', $parentid = 0, $areaid = 0, $property = '')
	{
		global $tree, $AREA;
		if(!is_object($tree))
		{
			require_once 'tree.class.php';
			$tree = new tree;
		}
		if(!$id) $id = $name;
		$data = "<select name='$name' id='$id' $property>\n<option value='0'>$alt</option>\n";
		if(is_array($AREA))
		{
			$areas = array();
			foreach($AREA as $id=>$a)
			{
				$areas[$id] = array('id'=>$id, 'parentid'=>$a['parentid'], 'name'=>$a['name']);
			}
			$tree->tree($areas);
			$data .= $tree->get_tree($parentid, "<option value='\$id' \$selected>\$spacer\$name</option>\n", $areaid);
		}
		$data .= '</select>';
		return $data;
	}
	*/

	/*
	function select_urlrule($module = 'phpcms', $file = 'category', $ishtml = 1, $name = 'urlruleid', $id ='', $urlruleid = 0, $property = '')
	{
		global $db;
		$urlrules = array();
		$result = $db->query("SELECT `urlruleid`,`example` FROM `".DB_PRE."urlrule` WHERE `module`='$module' AND `file`='$file' AND `ishtml`='$ishtml' ORDER BY `urlruleid`");
		while($r = $db->fetch_array($result))
		{
			$urlrules[$r['urlruleid']] = $r['example'];
		}
		$db->free_result($result);
		if(!$id) $id = $name;
		return Soooner_View_Helper_Form::select($urlrules, $name, $id, $urlruleid, 1, '', $property);
	}
	*/
}

